package Books2;

/**
 * 以面向对象的思想，编写自定义类描述图书信息。设定属性包括：书名，作者，出版社名，价格；方法包括：信息介绍
 * 1)设置属性的私有访问权限，通过公有的get,set方法实现对属性的访问
 * 2)限定介格必须大于10，如果无效进行提示
 * 3)限定作者，书名境外为只读属性
 * 4)设计构造方法实现对属性赋值
 * 5)信息介绍方法描述图书所有信息
 * 6)编写测试类，测试图书类的对象及相关方法（测试数据信息自定）
 */
public class Book {
     private String bookName;//书名
     private String author;//作者
     private String press;//出版社
     private double price;//价格


    public String getBookName(){
        return bookName;
    }
    public void setBookName(String bookName){
        this.bookName = bookName;
    }
    public String getAuthor(){
        return author;
    }
    public void setAuthor(String author){
        this.author = author;
    }
    public String getPress(){
        return press;
    }
    public void setPress(String press){
        this.press = press;
    }

    public double getPrice() {
        return price;
    }
    public void setPrice(double price){
      if (price > 10){
          this.price = price;
      }else {
          System.out.println("价格有误！");
      }
    }
    public double getprice(){
        return price;
    }
    public Book(String bookName,String author,String press,double price){
        this.bookName = bookName;
        this.author = author;
        this.press = press;
        this.setPrice(price);
    }
    public void show(){
        System.out.println("图书名称："+ this.getBookName());
        System.out.println("作者：" + this.getAuthor());
        System.out.println("出版社：" + this.getPress());
        System.out.println("价格：" + this.getprice() + "元");

    }

    public static void main(String[] args) {
        Book b1 = new Book("鹿鼎记","金庸","人民文学出版社",28.00);
        Book b2 = new Book("绝代双骄","古龙","中国长安出版社",23.00);
        b1.show();
        System.out.println("====================");
        b2.show();
    }


}
